package com.htiiot.status.cmd;

import org.apache.commons.cli.*;

/**
 *
 * @author 李延念
 * @create 2018-09-26 9:44
 *
 */
public class Cmd {
	public static void parserCmd(String[] args) {
		Options options = new Options();
		options.addOption("h", "help", false, "Print this usage information");
		options.addOption("z", "zookeeper", true, "The connection info of zk,like:master.htdata.com:2181");
		CommandLine cmd=null;
		CommandLineParser parser = new BasicParser();
		try {
			cmd = parser.parse(options, args);
		} catch (org.apache.commons.cli.ParseException e1) {
			HelpFormatter formatter = new HelpFormatter();
			formatter.printHelp("Status", options);
			e1.printStackTrace();
			System.exit(0);
		}
		if(cmd.hasOption("h")){
			HelpFormatter formatter = new HelpFormatter();
			formatter.printHelp("Status", options);
			System.exit(0);
		}
		
		if(cmd.hasOption("z")){
			System.setProperty("htiiot.zookeeper", cmd.getOptionValue("z"));
		}
	}

}
